Rendering Functions

# 6 Rendering Functions

The AGB CPU has 96 Kbytes of built-in VRAM.

Its rendering functions include BG and OBJ display capability. The method used for BG rendering varies with the BG mode, as described below.

## 6.1 Character Mode BG (BG Modes 0-2)

In character mode, the components of the BG screen are basic characters of 8 x 8 dots.

### 6.1.1 BG Control

There are 4 BG control registers, corresponding to the maximum number of BG screens (registers BG0CNT, BG1CNT, BG2CNT, and BG3CNT).

Registers BG0CNT and BG1CNT are exclusively for text BG control, while BG2CNT and BG3CNT also support BG rotation and scaling control.

The registers used by the BG modes are as follows.

BG Mode | BG Control Register
BG0CNT | BG1CNT | BG2CNT | BG3CNT
0 | BG0 (text) | BG1 (text) | BG2 (text) | BG3 (text)
1 | BG0 (text) | BG1 (text) | BG2 (rotation/scaling) | ---
2 | --- | --- | BG2 (rotation/scaling) | BG3 (rotation/scaling)

The contents of the BG control registers are shown below.

#### 1) Text BG Screen Control (BG0, BG1)

#### 2) Text BG and Rotation/Scaling BG Screen Control (BG2 and BG3)

Whether the screen is a text screen or a scaling/rotation screen varies with the BG mode.

BG*CNT [d15-14] Screen Size

Allows the screen size for the BG as a whole to be specified.

When a value other than the maximum is specified, the remaining VRAM area can be used as a character data area.

Refer to the table below and the VRAM Memory Map figure above.

Screen Size Setting | Text Screen | Rotation/Scaling Screen
Screen Size | Screen Data | Screen Size | Screen Data
00 | 256×256 | 2 Kbytes | 128×128 | 256 Bytes
01 | 512×256 | 4 Kbytes | 256×256 | 1 Kbyte
10 | 256×512 | 4 Kbytes | 512×512 | 4 Kbytes
11 | 512×512 | 8 Kbytes | 1024×1024 | 16 Kbytes

1) Overview of Screen Sizes for Text BG Screens

2) Illustration of Screen Sizes for Rotation/Scaling BG Screens

BG2CNT,BG3CNT [d13] Area Overflow Processing

When the display screen overflows the boundaries of the virtual screen due to a rotation/scaling operation, this bit can be used to choose whether the area of the screen into which the overflow occurs is displayed as transparent or wraps around the display screen.

For information on scaling, see 6.1.7 BG Rotation and Scaling Features.

BG*CNT [d12-08] Screen Base Block Specification

Specifies the starting block in VRAM where screen data are stored. (32 steps: 0-31; 2-Kbyte increments).

See section 6.1.3, VRAM Address Mapping of BG Data.

BG*CNT [d07] Color Mode

Specifies whether to reference BG character data in 16 color x 16 palette format or 256 color x 1 palette format.

BG*CNT [d06] Mosaic

Turns mosaic processing for BG on and off.

BG*CNT [d03-02] Character Base Block Specification

Specifies the starting block in VRAM where the character data to be displayed in the BG is stored.

(4 steps: 0-3; 16-Kbyte increments)

See section 6.1.3, VRAM Address Mapping of BG Data.

BG*CNT [d01-00] Priority Among BGs

With the default value (same priority value specified for all), the order of priority is BG0, BG1, BG2, and BG3. However, this order can be changed to any desired.

Values of 0 (highest priority) to 3 can be specified.

When the BG priority has been changed, care should be taken in specifying the pixels used for color special effects.

### 6.1.2 Mosaic Size

Mosaic size is set in the MOSAIC register. Turning mosaic on/off for each BG is accomplished by the mosaic flag of the BG control register. For information on the mosaic flag, see the previous chapter, BG Control.

The mosaic value specifies how many dots of a normal display should comprise each large dot displayed.

Counting from the upper left-most dot on the screen, the number of dots equal to the mosaic size are used in the mosaic display. The other dots are overwritten by the mosaic. Please refer to the figure below.

If the mosaic size value is 0, a normal display is seen even if mosaic is turned on.

Mosaic Schematic

### 6.1.3 VRAM Address Mapping of BG Data

BG data (BG character and screen data) are stored in the 64-Kbyte BG area of VRAM.

#### 1) BG Character Data

The starting address for referencing BG character data can be specified using the character base block specification of the BG control register.

The amount of data depends on the number of character data items stored and the data format (color formats: 256 colors x 1 palette or 16 colors x 16 palettes).

#### 2) BG Screening Data

The starting address for referencing BG screen data can be set using the screen base block specification of the BG control register.

The amount of data depends on the type of BG screen (text or rotation/scaling) and the screen size. These can be set by the BG control register.

#### Illustration of VRAM Base Blocks for BG Data

### 6.1.4 Character Data Format

There are two formats for character dot data, 16 color x 16 palettes and 256 colors x 1 palette. The same format is used for OBJ and BG.

The data are held in VRAM in the form indicated below.

#### 1) 16 Colors x 16 Palettes

There are 2 dots per address. Thus, the amount of data for each basic character is 20H x 8 bits.

#### 2) 256 Colors x 1 Palette

There is 1 dot specified per address. Thus, the amount of data for each basic character is 40H x 8 bits.

### 6.1.5 BG Screen Data Format

A BG screen is considered to be the 8 x 8 dot unit that represents the size of the basic character, and the BG screen data specifies the characters that are arranged.

BG screen data should be stored, beginning from the starting address of the BG screen base block specified in the BG control register. The number of screen data items specified per BG depends on the screen size setting in the BG control register.

BG screen data for text and rotation/scaling screens are specified in the following formats.

#### 1) Text BG Screen

A text BG screen consists of 2 bytes of screen data per basic character; 1,024 character types can be specified.

[d15-12] Color Palette

If the color mode specification in the BG control register is 16 colors x 16 palettes, these bits specify palette 0-15 as the palette to be applied to the character.

This is disabled when the color mode specification is 256 x 1 palette.

[d11] Vertical Flip Flag

Enables the BG character to be flipped vertically.

A setting of 1 produces the vertical-flip display.

[d10] Horizontal Flip Flag

Enables the BG character to be flipped horizontally.

A setting of 1 produces the horizontal-flip display.

[d09-00] Character Name

Specify the number of the character that has character base block starting address specified in the BG control register as its starting point.

#### 2) Rotation/Scaling BG Screen

The rotation/scaling BG screen consists of 1 byte of screen data per basic character; 256 character types can be specified. The character data must be classified as 256 colors x 1 palette. The color mode specification in the BG control register is disabled for a rotation/scaling screen.

[Cautions for VRAM]

AGB provides a high degree of freedom in using the BG area of VRAM.

Consequently, in managing VRAM, the following points deserve particular attention.

1. There are 2 formats for BG character data (defined by 16 and 256 colors), and these can be used together.
2. The BG character data base block can be selected from among 4 blocks (BG control register).
3. The BG screen data base block can be selected from among 32 blocks (BG control register).
4. The screen size (amount of VRAM used) can be set for each BG (BG control register).
5. Text and rotation/scaling BGs can be present and used together in a BG screen.

In managing VRAM, particular care is required in BG mode 1, because text BG screens (which can handle BG character data in both 256 colors x 1 palette and 16 colors x 16 palettes) and rotation/scaling BG screens (which can handle only 256 colors x 1 palette) may be used together.

Therefore, the VRAM mapping status should be sufficiently understood when programming.

### 6.1.6 BG Screen Data Address Mapping for the LCD Screen

#### 1) Text BG

- 1-1) Virtual Screen Size of 256 x 256 Dots

- 1-2) Virtual Screen Size of 512 x 256 Dots

- 1-3) Virtual Screen Size of 256 x 512 Dots

- 1-4) Virtual Screen Size of 512 x 512 Dots

#### 2) Rotation/scaling BG

- 2-1) Virtual Screen Size of 128 x 128 Dots

- 2-2) Virtual Screen Size of 256 x 256 Dots

- 2-3) Virtual Screen Size of 512 x 512 Dots

- 2-4) Virtual Screen Size of 1024 x 1024 Dots

### 6.1.7 BG Rotation and Scaling Features

Rotation and scaling of the BG as a whole can be performed in a rotation/scaling BG screen.

With rotation, BG data is referenced as shown in the following figure.

BG rotation and scaling are implemented in AGB using the following arithmetic expressions.

Parameters used in rotation and scaling operations are specified for BG2 and BG3 in the following registers. Registers for Starting Point of BG Data Reference are also used when Scaling/Rotation BG and Bitmap Mode BG are offset displayed (scrolled). (There is also an offset register for Text BG.)

#### Registers for Setting the Starting Point of BG Data

#### Registers for Setting the Direction Parameters of BG Data

#### Operations Used in BG Rotation/Scaling Processing

1. Using software, the user determines the results of the rotation/scaling operation for the left-upper coordinate of the display screen and sets this as the starting point of the BG data reference in registers BG2X_L, BG2X_H, BG2Y_L, BG2Y_H, BG3X_L, BG3X_H, BG3Y_L, and BG3Y_H. The set value is a signed fixed-point number (8 bits for fractional portion, 19 bits for integer portion, and 1 bit for sign, for a total of 28 bits).

   The BG data reference direction is set in BG2PA, BG2PB, BG2PC, BG2PD, BG3PA, BG3PB, BG3PC, and BG3PD. The set value is a signed fixed-point number (8 bits for fractional portion, 7 bits for integer portion, and 1 bit for sign, for a total of 16 bits).

2. The image processing circuit sums the increases in the x direction (dx, dy) in relation to the BG data reference starting point set in the above registers, and calculates the x-coordinate.
3. When the line is advanced, the increases in the y direction (dmx, dmy) are summed in relation to the reference starting point, and the coordinate of the rendering starting point for the next line is calculated. The processing in step 2) is then performed.
4. However, if a register for the BG data reference starting point is rewritten during an H-blanking interval, the y-direction summation for that register is not calculated. The CPU uses this mode to change the center coordinate and rotation/scaling parameters for each line.

#### Area Overflow Processing

When the display screen overflows the boundaries of the virtual screen due to a rotation/scaling operation, this BG control register can be used to select whether the area of the screen into which the overflow occurs is transparent or wraps around the display screen.

For information on BG control, see "6.1.1 BG Control".

### 6.1.8 BG Scrolling

For each text BG screen, the offset on the display screen can be specified in 1-dot increments. Offset register is only valid for Text BG. In order to offset display Scaling/Rotation BG and Bitmap Mode BG set the BG Reference Starting Point. See "6.1.7, BG Rotation and Scaling Features".

#### Offset Settings Registers

#### Offset Illustration

## 6.2 Bitmap Mode BGs (BG Modes 3-5)

In the bitmap modes, the components of the BG screen are handled in pixel units, and the contents of VRAM (frame buffer) are displayed as color data for each dot on the screen.

### 6.2.1 BG Control

The bitmap BG will be treated as BG2. Therefore, in order to display the content of the frame buffer on the LCD screen, you need to set the BG2 display flag to ON in the DISPCNT Register. For BG Control the BG2CNT Register is used. BG2CNT [d06] Mosaic

This controls the ON/OFF of mosaic processing for BG2. When ON, the settings for the Mosaic Size Register, MOSAIC, are referenced. For information on Mosaic, see "6.1.2 Mosaic Size".

BG2CNT [d01-00] Priority Among BGs

Due to the fact that in Bitmap Mode there is only one BG plane(other than the backdrop plane), there is no priority relationship among BGs, but you can set up priorities with OBJ. For information on this, see "6.4 Display Priority of OBJ and BG".

### 6.2.2 BG Rotation/Scaling

The parameters for Bitmap BG Rotation/Scaling use BG2 related registers(BG2X_L, BG2X_H, BG2Y_L, BG2Y_H, BG2PA, BG2PB, BG2PC, and BG2PD).

For information on rotation/scaling parameters, see "6.1.7 BG Rotation/Scaling Features".

With Bitmap BG, if the displayed portion exceeds the edges of the screen due to the rotation/scaling operation, that area becomes transparent.

### 6.2.3 Pixel Data

In the bitmap modes, only the amount of pixel data corresponding to the size of the display screen can be stored in VRAM. Available bitmap modes allow the simultaneous display of 32,768 colors (BG modes 3 and 5) and the display of 256 of the 32,768 colors (BG mode 4). The format of the data in the frame buffer differs between the modes as described below.

1. 32,768-Color Simultaneous Display Format (BG Modes 3 and 5)

Palette RAM is not referenced.

Each pixel uses a half-word.

2. 256-Color (of 32,768) Display Format (BG Mode 4)

Palette RAM color data (256 of the 32,768 colors storable) are referenced.

Each pixel uses 1 byte.

###

### 6.2.4 Pixel Data Address Mapping for the LCD Screen

The different address mappings for the different BG modes are shown below.

The frame buffer (VRAM) starts at address 06000000h. Thus, to see the addresses used by the CPU, add 06000000h to the addresses shown below.

####

#### 6.2.4.1 BG Mode 3 (32,768 colors, 240X160 dots, 1 frame buffer)

Because there is a single frame buffer, this mode is used mainly for still images. However, it enables 32,768 colors to be displayed simultaneously over the full screen.

| 0 | 1 | 2 | 3 | 4 | ... | 236 | 237 | 238 | 239
0 | 0h | 2h | 4h | 6h | 8h | ... | 1D8h | 1Dah | 1DCh | 1DEh
1 | 1E0h | 1E2h | 1E4h | 1E6h | 1E8h | ... | 3B8h | 3Bah | 3BCh | 3BEh
2 | 3C0h | 3C2h | 3C4h | 3C6h | 3C8h | ... | 598h | 59Ah | 59Ch | 59Eh
3 | 5A0h | 5A2h | 5A4h | 5A6h | 5A8h | ... | 778h | 77Ah | 77Ch | 77Eh
4 | 780h | 782h | 784h | 786h | 788h | ... | 958h | 95Ah | 95Ch | 95Eh
156 | 12480h | 12482h | 12484h | 12486h | 12488h | ... | 12658h | 1265Ah | 1265Ch | 1265Eh
157 | 12660h | 12662h | 12664h | 12666h | 12668h | ... | 12838h | 1283Ah | 1283Ch | 1283Eh
158 | 12840h | 12842h | 12844h | 12846h | 12848h | ... | 12A18h | 12A1Ah | 12A1Ch | 12A1Eh
159 | 12A20h | 12A22h | 12A24h | 12A26h | 12A28h | ... | 12BF8h | 12BFAh | 12BFCh | 12BFEh

VRAM address (+06000000h)

#### 6.2.4.2 BG Mode 4 (256 colors, 240X160 dots, 2 frame buffers)

Two frame buffers are allocated in VRAM, making this mode suitable for full-motion video. Of the total of 32,768 colors, 256 can be displayed simultaneously over the full screen.

1. Frame 0

   | 0 | 1 | 2 | 3 | 4 | ... | 236 | 237 | 238 | 239
   0 | 0h | 1h | 2h | 3h | 4h | ... | ECh | EDh | EEh | EFh
   1 | F0h | F1h | F2h | F3h | F4h | ... | 1DCh | 1DDh | 1DEh | 1DFh
   2 | 1E0h | 1E1h | 1E2h | 1E3h | 1E4h | ... | 2CCh | 2CDh | 2CEh | 2CFh
   3 | 2D0h | 2D1h | 2D2h | 2D3h | 2D4h | ... | 3BCh | 3BDh | 3BEh | 3BFh
   4 | 3C0h | 3C1h | 3C2h | 3C3h | 3C4h | ... | 4ACh | 4ADh | 4AEh | 4AFh
   156 | 9240h | 9241h | 9242h | 9243h | 9244h | ... | 932Ch | 932Dh | 932Eh | 932Fh
   157 | 9330h | 9331h | 9332h | 9333h | 9334h | ... | 941Ch | 941Dh | 941Eh | 941Fh
   158 | 9420h | 9421h | 9422h | 9423h | 9424h | ... | 950Ch | 950Dh | 950Eh | 950Fh
   159 | 9510h | 9511h | 9512h | 9513h | 9514h | ... | 95FCh | 95FDh | 95FEh | 95FFh

   VRAM address (+06000000h)

2. Frame 1

| 0 | 1 | 2 | 3 | 4 | ... | 236 | 237 | 238 | 239
0 | A000h | A001h | A002h | A003h | A004h | ... | A0ECh | A0EDh | A0EEh | A0EFh
1 | A0F0h | A0F1h | A0F2h | A0F3h | A0F4h | ... | A1DCh | A1DDh | A1DEh | A1DFh
2 | A1E0h | A1E1h | A1E2h | A1E3h | A1E4h | ... | A2CCh | A2CDh | A2CEh | A2CFh
3 | A2D0h | A2D1h | A2D2h | A2D3h | A2D4h | ... | A3BCh | A3BDh | A3BEh | A3BFh
4 | A3C0h | A3C1h | A3C2h | A3C3h | A3C4h | ... | A4ACh | A4ADh | A4AEh | A4AFh
156 | 13240h | 13241h | 13242h | 13243h | 13244h | ... | 1332Ch | 1332Dh | 1332Eh | 1332Fh
157 | 13330h | 13331h | 13332h | 13333h | 13334h | ... | 1341Ch | 1341Dh | 1341Eh | 1341Fh
158 | 13420h | 13421h | 13422h | 13423h | 13424h | ... | 1350Ch | 1350Dh | 1350Eh | 1350Fh
159 | 13510h | 13511h | 13512h | 13513h | 13514h | ... | 135FCh | 135FDh | 135FEh | 135FFh

VRAM address (+06000000h)

#### 6.2.4.3 BG Mode 5 (32,768 colors, 160X128 dots, 2 frame buffers)

Although there are 2 frame buffers, the display area is limited in this mode to enable simultaneous display of 32,768 colors.

1. Frame 0

| 0 | 1 | 2 | 3 | 4 | ... | 156 | 157 | 158 | 159
0 | 0h | 2h | 4h | 6h | 8h | ... | 138h | 13Ah | 13Ch | 13Eh
1 | 140h | 142h | 144h | 146h | 148h | ... | 298h | 29Ah | 29Ch | 29Eh
2 | 2A0h | 2A2h | 2A4h | 2A6h | 2A8h | ... | 3B8h | 3BAh | 3BCh | 3BEh
3 | 3C0h | 3C2h | 3C4h | 3C6h | 3C8h | ... | 4F8h | 4FAh | 4FCh | 4FEh
4 | 500h | 502h | 504h | 506h | 508h | ... | 638h | 63Ah | 63Ch | 63Eh
124 | 9B00h | 9B02h | 9B04h | 9B06h | 9B08h | ... | 9C38h | 9C3Ah | 9C3Ch | 9C3Eh
125 | 9C40h | 9C42h | 9C44h | 9C46h | 9C48h | ... | 9D78h | 9D7Ah | 9D7Ch | 9D7Eh
126 | 9D80h | 9D82h | 9D84h | 9D86h | 9D88h | ... | 9EB8h | 9EBAh | 9EBCh | 9EBEh
127 | 9EC0h | 9EC2h | 9EC4h | 9EC6h | 9EC8h | ... | 9FF8h | 9FFAh | 9FFCh | 9FFEh

VRAM Address (+06000000h)

2. Frame 1

| 0 | 1 | 2 | 3 | 4 | ... | 156 | 157 | 158 | 159
0 | A000h | A002h | A004h | A006h | A008h | ... | A138h | A13Ah | A13Ch | A13Eh
1 | A140h | A142h | A144h | A146h | A148h | ... | A298h | A29Ah | A29Ch | A29Eh
2 | A2A0h | A2A2h | A2A4h | A2A6h | A2A8h | ... | A3B8h | A3BAh | A3BCh | A3BEh
3 | A3C0h | A3C2h | A3C4h | A3C6h | A3C8h | ... | A4F8h | A4FAh | A4FCh | A4FEh
4 | A500h | A502h | A504h | A506h | A508h | ... | A638h | A63Ah | A63Ch | A63Eh
124 | 13B00h | 13B02h | 13B04h | 13B06h | 13B08h | ... | 13C38h | 13C3Ah | 13C3Ch | 13C3Eh
125 | 13C40h | 13C42h | 13C44h | 13C46h | 13C48h | ... | 13D78h | 13D7Ah | 13D7Ch | 13D7Eh
126 | 13D80h | 13D82h | 13D84h | 13D86h | 13D88h | ... | 13EB8h | 13EBAh | 13EBCh | 13EBEh
127 | 13EC0h | 13EC2h | 13EC4h | 13EC6h | 13EC8h | ... | 13FF8h | 13FFAh | 13FFCh | 13FFEh

VRAM address (+06000000h)

##

## 6.3 OBJ (Object)

###

### 6.3.1 OBJ Function Overview

Objects are in character format regardless of the BG mode. However, the number of basic characters that can be defined varies depending on the BG mode.

Item | Function
Number of display colors | 16 colors/16 palettes or 256 colors/1 palette (mixed display possible)
Number of characters (8x8 dots) | 1,024 (16 colors x 16 palettes) : in BG modes 0-2 512 (256 colors x 1 palette) : " 512 (16 colors x 16 palettes) : in BG modes 3-5 256 (256 colors x 1 palette) : "
Character size | 8x8 - 64x64 dots (12 types)
Max. number per screen | 128 (64x64 dot conversion)
Max. number per line | 128 (8x8 dot conversion)
Color special effects | HV flip, semi-transparency, mosaic, priority specification, OBJ windows

#### OBJ Display Capability on a Single Line

The single-line OBJ display capability shown in the table above, is the capability at maximum efficiency.

When the displayed OBJ are arranged continuously from the start of OAM, you can calculate the OBJ display capability on a single line using the following formula:

(Number of H Dots × 4 - 6) / Number of Rendering Cycles =
OBJ Displayable on a single line (Max. of 128)

The "Number of H Dots" is usually 308 dots, but when the H-Blank Interval OBJ Processing Flag for Register DISPCNT is set to 1, there are 240 dots (Refer to "4 LCD").

"×4" expresses the number of cycles that the OBJ Rendering Circuit can use per one dot. "-6" represents the number of cycles needed for processing before OBJ rendering at the start of the H Line.

The "Number of Rendering Cycles" and the corresponding number of OBJ displayable for a single line is expressed in the table below.

OBJ H Size | Number of Rendering Cycles | Number of OBJ displayable on single line
Normal OBJ | Rotation/Scaling OBJ | Normal OBJ | Rotation/Scaling OBJ
8 | 8 | 26 | 128 | 47
16 | 16 | 42 | 76 | 29
32 | 32 | 74 | 38 | 16
64 | 64 | 138 | 19 | 8
128 (double the size of 64) | X | 266 | X | 4

If the number for non-displayed (outside of the screen) OBJ's in the OAM is lower than that for displayed OBJ's, the larger the non-displayed OBJ's size is, the less effecient the rendering will be. Please be aware of this problem.

### 6.3.2 Character Data Mapping

With OBJ character data, the basic character is 8 x 8 dots, and characters between 8 x 8 and 64 x 64 dots can be handled (total of 12 types). The base address of OBJ character data is a fixed VRAM base address. The OBJ character data capacity allocated is either 32 Kbytes or 16 Kbytes, depending on the BG mode (see 5.1.2 "VRAM Memory Map").

There are 2 types of mapping to the character area, and they can be specified in bit [d06] of the DISPCNT register .
OBJ is managed by character numbers that are divided by 32 bytes starting with the OBJ character database address. 32 bytes is the required capacity to define 1 basic character of 16 colors x 16 palettes. 64 bytes is the required capacity to define 1 basic character of 256 colors x 1 palette.

#### 1) VRAM 2-Dimensional Mapping for OBJ Characters

Setting the DISPCNT register bit [d06] to 0 results in the 2-dimensional mapping mode shown in the following figure.

[Cautions for Character Name]
When a character of 256 colors x 1 palette is displayed during the 2 dimensional mapping mode, specifying a character name is limited to even numbers (see OBJ attribute 2 of OAM). So, in most cases when defining a character of 256 colors x 1 palatte during the 2 dimensional mapping mode, you define it so that a character name is an even number.

#### 2) VRAM 1-Dimensional Mapping for OBJ Characters

Setting DISPCNT register bit [d06] to 1 results in the 1-dimensional mapping mode shown in the following figure.

The data that comprise a character are stored in contiguous addresses.

### 6.3.3 OAM

OBJs are displayed by placing data in OAM.

OBJ data for 128 OBJs can be written to internal CPU OAM (addresses 07000000h-070003FFh), and 128 OBJ characters of an arbitrary size can be displayed on the LCD.

#### OAM Mapping

OBJ attributes occupying 48 bits x 128 OBJs can be written to OAM.

In addition, when rotation/scaling are performed for an OBJ, a total of 32 instances of rotation/scaling parameter combinations (PA, PB, PC, and PD) can be written to OAM, as shown in the following figure.

OBJ Attribute 0

[d15-14] OBJ Shape

Selects the OBJ Character Shape: Square, Horizontal Rectangle, or Vertical Rectangle.

11 is a prohibited code.

Please also refer to OBJ size specification for OBJ Attribute 1.

[d13] Color Mode Flag

Specifies whether the OBJ data format is 16 colors x 16 palette mode or 256 colors x 1 palette mode.

[d12] OBJ Mosaic Flag

Turns mosaic for OBJs on and off.

[d11-10] OBJ Mode

Specifies whether an OBJ is a normal OBJ or a semitransparent OBJ.

A normal OBJ is specified by 00, a semi-transparent OBJ by 01, and an OBJ window by 10.

A value of 11 is a prohibited code, so care should be taken to prevent this setting.

When a semi-transparent OBJ is specified, color special effects processing can be performed. For information on color special effects, see "9 Color Special Effects".

OBJs for which an OBJ window specification is used are not displayed as normal OBJs; dots with non-zero character data are used as the OBJ window.

[d09] Rotation/Scaling Double-Size Flag

OBJs are limited in size by the OBJ field (8x8 - 64x64 dots), and the character data may surpass the boundaries of this field when rotated.

This problem can be avoided by implementing a pseudo double-size for the OBJ field, by setting the double-size flag to 1.

With this setting, the OBJ does not surpass the boundaries of the OBJ field even if the OBJ display is magnified by up to two-fold.

Example: 64x64 dot OBJ field 128x128 dot field displayed with rotation processing. Note, however, that the OBJ display position is shifted.

With the double-size flag set to 0, display of the portion protruding from the edges is cut off.

Please refer to the following figure.

[d08] Rotation/Scaling Flag

Allows rotation processing for the OBJ to be enabled and disabled.

With the OBJ rotation/scaling feature enabled by setting this bit to 1, the maximum number of OBJs displayed per line is decreased. Please refer to the description in Section 6.3.1 on "OBJ Display Capability on a Single Line".

[d07-00] Y-Coordinate

Allows the y-coordinate of the OBJ in the display screen to be specified.

[Cautions]

160 dots in total (0-159) are inside the display screen and 96 dots in total (160-255) are outside the display screen (virtual screen).

When the vertical size displays a 64 dot OBJ by a double size of character, the size is 128 dots, exceeding the vertical 96 dots for the virtual screen.

Therefore, in the range of Y coordinate values of 129-159, the lower part of OBJ that is pushed out upwards is displayed. The upper part of OBJ in the lower screen is not displayed (see below).

OBJ Attribute 1

[d15-14] OBJ Size

Linked to the specification of the OBJ size for Attribute 0, the size for the OBJ Character is also specified. For each of the three OBJ shapes, you can set four sizes.

[d13] [d12] Vertical and Horizontal Flip Flags

Allows the OBJ to be flipped horizontally and vertically.

A normal display is produced by a setting of 0 and a flip display by a setting of 1.

When the rotation/scaling flag ([d08] of OBJ Attribute 0) is enabled, these bits also can be used as the high-order bits of the rotation/scaling parameter selection.

[d13-09] Rotation/Scaling Parameter Selection

The parameters used in OBJ rotation/scaling processing are selected from the 32 parameters registered in OAM.

[d08-00] X-Coordinate
Specifies the x-coordinate of the OBJ on the display screen in the range of 0~511.

OBJ Attribute 2

[d15-12] Color Palette No.

When 16 colors x 16 palette format is specified in the color mode bit, these bits specify 1 of the 16 palettes to apply to the character data.

When 256 colors x 1 palette format is specified in the color mode bit, these bits are disabled.

[d11-10] Priority Relative to BG

Specifies the display priority of the OBJ relative to BG. For information on priority, see section 6.4, Display Priority of OBJ and BG.

[d09-00] Character Name

Writes the number of the basic character located at the start of the OBJ character data mapped in VRAM. (See section 6.3.2, Character Data Mapping).

16 colors x 16 palettes (color mode=1)

Allows selection of 1,024 characters.

256 colors x 1 palette (color mode=0)

Allows selection of 512 characters.

Bit 0 fixed at 0 in 2-dimensional mapping mode.

BG Mode is 3~5 (Bitmap Mode)

OBJ character data RAM is halved to 16 KB, so character name numbers 0-511 are disabled and numbers 512 and greater are used.

### 6.3.4 OBJ Rotation/Scaling Feature

The rotation and scaling feature for OBJ is essentially the same as that for BG.

OBJ Character Data Referenced with Rotation

When an OBJ is displayed, the OBJ character data are referenced horizontally, beginning from the left-uppermost position. Rotation display can be achieved by adding an angle to the reference direction. The center of rotation is fixed at the center of the OBJ field. If a reference point surpasses the specified OBJ size, it becomes transparent.

#### Operations Used in OBJ Rotation/Scaling Processing

1. Specify the rotation/scaling parameter number to be applied in OBJ Attribute 1 of the OAM.
2. The image-processing circuit sums the increases in the x direction (dx, dy) in relation to the center of rotation (OBJ field center), which serves as reference point, to calculate the x-direction coordinates.
3. When the line is advanced, the increases in the y-direction (dmx, dmy) in relation to the reference point, are summed to calculate the coordinate of the starting point for rendering the next line. The processing in step 2) above, is then performed.

#### Rotation/Scaling Parameters

Specifies the direction of character data reference in OBJ rotation/scaling processing. (See the following chapter for more information.)

The values set for PA, PB, PC, and PD are signed, fixed-point numbers (8-bit fractional portion, 7-bit integer portion, 1-bit sign, for a total of 16 bits).

These 4 parameters are used together as a single group, which can be placed in any of 32 areas in OAM.

##

## 6.4 Display Priority of OBJ and BG

### 1) Priority Among BGs

Priority among BGs can be set to any of 4 levels.

When BGs have the same priority setting, the BG with the lowest BG number is given priority.

### 2) Priority Among OBJs

Priority among OBJs can be set to any of 4 levels.

When OBJs have the same priority setting, the OBJ with the lowest OBJ number is given priority.

### 3) Priority Among BGs and OBJs

The priority of each OBJ in relation to the BG can be set to 4 levels. Please refer to the following figure.

[Cautions for Priority]

When orders of OBJ number and OBJ priority are reversed, the display is not right if BG is between the OBJs. Please be cautious not to let this situation occur.

Examples of when the display is not right:

OBJ-No.0 (OBJ priority 2) BG (BG priority 1) OBJ-No.1 (OBJ priority 0)